package com.tencreat.service.mall.impl;

import java.time.LocalDateTime;
import java.util.List;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tencreat.common.core.domain.model.ReqIdParam;
import com.tencreat.common.core.domain.model.ReqIdsParam;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tencreat.domain.mall.MallGoodsHelpCutUser;
import com.tencreat.domain.mall.dto.MallGoodsHelpCutUserDTO;
import com.tencreat.mapper.mall.MallGoodsHelpCutUserMapper;
import com.tencreat.service.mall.IMallGoodsHelpCutUserService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
 * 帮砍记录Service业务层处理
 *
 * @author wangkai
 * @date 2021-11-04
 */
@Service
public class MallGoodsHelpCutUserServiceImpl extends ServiceImpl<MallGoodsHelpCutUserMapper, MallGoodsHelpCutUser> implements IMallGoodsHelpCutUserService {


    /**
     * 查询帮砍记录
     *
     * @param id 帮砍记录ID
     * @return 帮砍记录
     */
    @Override
    public MallGoodsHelpCutUser selectMallGoodsHelpCutUserById(ReqIdParam id) {
        return baseMapper.selectById(id.getId());
    }

    /**
     * 查询帮砍记录列表
     *
     * @param mallGoodsHelpCutUser 帮砍记录
     * @return 帮砍记录
     */
    @Override
    public List<MallGoodsHelpCutUser> selectMallGoodsHelpCutUserList(MallGoodsHelpCutUser mallGoodsHelpCutUser) {
        return baseMapper.selectList(Wrappers.query(mallGoodsHelpCutUser));
    }

    /**
     * 新增帮砍记录
     *
     * @param
     * @return 结果
     */
    @Override
    public int insertMallGoodsHelpCutUser(MallGoodsHelpCutUserDTO mallGoodsHelpCutUserDTO) {
        MallGoodsHelpCutUser mallGoodsHelpCutUser = new MallGoodsHelpCutUser();
        BeanUtils.copyProperties(mallGoodsHelpCutUserDTO, mallGoodsHelpCutUser);
        mallGoodsHelpCutUser.setCreateTime(LocalDateTime.now());
        return baseMapper.insert(mallGoodsHelpCutUser);
    }

    /**
     * 修改帮砍记录
     *
     * @param
     * @return 结果
     */

    @Override
    public int updateMallGoodsHelpCutUser(MallGoodsHelpCutUserDTO mallGoodsHelpCutUserDTO) {
        MallGoodsHelpCutUser mallGoodsHelpCutUser = new MallGoodsHelpCutUser();
        BeanUtils.copyProperties(mallGoodsHelpCutUserDTO, mallGoodsHelpCutUser);
        mallGoodsHelpCutUser.setUpdateTime(LocalDateTime.now());
        return baseMapper.updateById(mallGoodsHelpCutUser);
    }

    /**
     * 批量删除帮砍记录
     *
     * @param ids 需要删除的帮砍记录ID
     * @return 结果
     */
    @Override
    public int deleteMallGoodsHelpCutUserByIds(ReqIdsParam ids) {
        return baseMapper.deleteBatchIds(ids.getId());
    }

    /**
     * 删除帮砍记录信息
     *
     * @param id 帮砍记录ID
     * @return 结果
     */
    @Override
    public int deleteMallGoodsHelpCutUserById(ReqIdParam id) {
        return baseMapper.deleteById(id.getId());
    }
}
